<template>
    <div>
        <el-popover
                placement="down"
                width="400"
                trigger="click" v-model="driverForm" ref="update_driver_modal" style="position: relative">
            <el-form ref="form" :model="driverList" label-width="150px" class="update-form">
                <el-form-item label="姓名">
                    <el-input v-model="driverList.drivername"></el-input>
                </el-form-item>
                <el-form-item label="身份证号">
                    <el-input v-model="driverList.drivinglicense"></el-input>
                </el-form-item>
                <el-form-item label="准驾车型">
                    <el-input v-model="driverList.vehicleclass"></el-input>
                </el-form-item>
                <el-form-item label="驾驶证发证机关">
                    <el-input v-model="driverList.issuingorganizations"></el-input>
                </el-form-item>
                <el-form-item label="驾驶证有效起始日期">
                    <el-input v-model="driverList.validperiodfrom"></el-input>
                </el-form-item>
                <el-form-item label="驾驶证有效终止日期">
                    <el-input v-model="driverList.validperiodto"></el-input>
                </el-form-item>
                <el-form-item label="从业资格证号">
                    <el-input v-model="driverList.qualificationcertificate"></el-input>
                </el-form-item>
                <el-form-item label="手机号码">
                    <el-input v-model="driverList.telephone"></el-input>
                </el-form-item>
                <el-form-item label="remark">
                    <el-input v-model="driverList.remark"></el-input>
                </el-form-item>
                <el-form-item label="appkey">
                    <el-input v-model="driverList.appkey"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit('driverForm')">立即创建</el-button>
                    <el-button @click="hideForm('driverForm')">取消</el-button>
                </el-form-item>
            </el-form>
            <el-button slot="reference">上传司机信息</el-button>
        </el-popover>
    </div>
</template>

<script>
    export default {
        name: "driver",
        data(){
            return {
                driverForm: false,
                driverList:{
                    drivername: '李广俊',  //姓名
                    drivinglicense: '210423197605212813',   //身份证号
                    vehicleclass: 'A2', //准驾车型
                    issuingorganizations: '辽宁省抚顺市公安局交通警察支队',    //驾驶证发证机关
                    validperiodfrom: '20100805',    //驾驶证有效期自
                    validperiodto: '20200805',  //驾驶证有效期至
                    qualificationcertificate: '210423197605212813', //从业资格证号
                    telephone: '13322302820',   //手机号码
                    remark: '', //
                    appkey: '13762',    //
                }
            }
        },
        methods: {
            defaultDriver() {
                return `
    <reqInfo>
    <root>
    <header>
    <messagereferencenumber>###UUID###</messagereferencenumber>
    <documentname>驾驶员信息</documentname>
    <documentversionnumber>2.0</documentversionnumber>
    <sendercode>210000</sendercode>
    <enterprisesendercode>2113762</enterprisesendercode>
    <messagesendingdatetime>###TIME###</messagesendingdatetime>
    <ipctype>WLHY_JSY1001</ipctype>
    <token>427690567060f4d98f24c10099fcaa98</token>
    <messagefunctioncode>9</messagefunctioncode>
    <recipientcode>wcjc0002</recipientcode>
    </header>
`
            },
            onSubmit(formName){
                this.hideForm(formName)
                let header = this.defaultDriver()
                let str = `
               ${header}<body>
	<drivername>${this.driverList.drivername}</drivername>
	<drivinglicense>${this.driverList.drivinglicense}</drivinglicense>
	<vehicleclass>${this.driverList.vehicleclass}</vehicleclass>
	<issuingorganizations>${this.driverList.issuingorganizations}</issuingorganizations>
	<validperiodfrom>${this.driverList.validperiodfrom}</validperiodfrom>
	<validperiodto>${this.driverList.validperiodto}</validperiodto>
	<qualificationcertificate>${this.driverList.qualificationcertificate}</qualificationcertificate>
	<telephone>${this.driverList.telephone}</telephone>
	<remark>${this.driverList.remark}</remark>
	<appkey>${this.driverList.appkey}</appkey>
</body>
</root>
</reqInfo>
                `

                console.log(str);
                this.cusMark()
                this.api.dataPost.driverInfo(str).then((res) => {
                    console.log(res);
                    this.handleRes(res)
                }).catch((res) => {
                    console.log(res);
                })
            },
        },
        mounted() {
        }
    }
</script>

<style scoped>

</style>